package cn.liontalk.common.result;

import lombok.Data;

/**
 * @author: 周哲
 * @package: cn.liontalk.common.result
 * @description:
 * @date: 2019/1/18 14:41
 * @version: V1.0
 */
@Data
public class CodeMsg {

    private int code;

    private String message;


    private CodeMsg(int code, String message) {
        this.code = code;
        this.message = message;
    }




    /**
     * 访问次数超过限制
     */
    public static CodeMsg ACCESS_LIMIT_REACHED = new CodeMsg(500101, "访问次数超过限制");


    /**
     * 非法请求
     */
    public static CodeMsg REQUEST_ILLEGAL = new CodeMsg(500101, "非法请求");


    /**
     * 秒杀失败
     */
    public static CodeMsg MIAOSHA_FAIL = new CodeMsg(500102, "秒杀失败");

    /**
     * 数据校验异常
     */
    public static CodeMsg BIND_ERROR = new CodeMsg(500103, "参数校验异常：%s");

    /**
     * 调用成功
     */
    public static CodeMsg SUCCESS = new CodeMsg(200, "操作成功");

    /**
     * 服务器错误
     */
    public static CodeMsg SERVER_ERROR = new CodeMsg(500104, "服务器错误");


    /**
     * 手机号码不能为空
     */
    public static CodeMsg MOBILE_NOT_EXIST = new CodeMsg(500200, "手机号码不存在");

    /**
     * 手机号码格式错误
     */
    public static CodeMsg MOBILE_PATTERN_ERROR = new CodeMsg(500201, "手机号码格式错误");


    /**
     * 密码不能为空
     */
    public static CodeMsg PASSWORD_IS_EMPTY = new CodeMsg(500203, "登录密码不能为空");


    /**
     * 用户不存在
     */
    public static CodeMsg USER_NOT_EXIST = new CodeMsg(500301, "用户不存在");


    /**
     * 密码错误
     */
    public static CodeMsg PASSWORD_ERROR = new CodeMsg(500302, "登录密码错误");


    /**
     * 重复秒杀
     */
    public static CodeMsg REPEAT_KILL = new CodeMsg(500303, "重复秒杀");




    /**
     * 库存不足
     */
    public static CodeMsg STOCK_NOT_ENOUGH = new CodeMsg(500304, "库存不足");


    /**
     * 用户SESSION过期,请重新登录
     */
    public static CodeMsg SESSION_ERROR = new CodeMsg(500305, "用户SESSION过期,请重新登录");


    /**
     * 请输入验证码
     */
    public static CodeMsg NEED_INPUT_VERIFY_CODE = new CodeMsg(500305, "请输入验证码");



    /**
     * 秒杀结束
     */
    public static CodeMsg MIAO_SHA_OVER = new CodeMsg(500306, "秒杀结束");


    /**
     * 验证码计算错误
     */
    public static CodeMsg VERIFY_CODE_ERROR = new CodeMsg(500308, "验证码计算错误");


    /**
     * 订单不存在
     */
    public static CodeMsg ORDER_NOT_EXIST = new CodeMsg(500307, "订单不存在");



    public CodeMsg fillArgs(Object... args) {
        int code = this.code;
        String message = String.format(this.message, args);
        return new CodeMsg(code, message);
    }
}
